package com.spc.car.data.domain.sys.po;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spc.car.common.utils.StringUtils;
import com.spc.car.data.annotation.Skip;
import com.spc.car.data.util.QueryUtil;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import java.util.Objects;

@Data
public class ManpowerRequisitionPO {

    @Skip
    @Min(value = 0)
    private Integer page = 0;
    @Skip
    @Range(min = 1, max = 30)
    private Integer pageSize = 10;

    private String projectTenderingCode;
    private String reviewerCode;
    private String applicantCode;
    private Long assistanceDepartmentId;
    private String status;

    public Wrapper toWrapper() {
        QueryWrapper wrapper = QueryUtil.toWrapper(this);
        wrapper.orderByDesc("priority", "applicant_time");

        return wrapper;
    }

    public boolean showMy() {
        return StringUtils.isBlank(projectTenderingCode)
                && StringUtils.isBlank(reviewerCode)
                && StringUtils.isBlank(applicantCode)
                && Objects.isNull(assistanceDepartmentId);
    }
}
